#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>

int my_number(int n)
{
    int nums = 0;
    int i = 0;
    while (n)
    {
        if (n & (1 << i))
        {
            nums++;
        }
        i++;
        n >>= 1;
    }
    return nums;
}
int* countBits(int n, int* returnSize) {
    int i = 0;
    int* arr = (int*)malloc(sizeof(int) * (n + 1));
    for (i = 0; i <= n; i++)
    {
        arr[i] = my_number(i);
    }
    return arr;
}


int main()
{
    int n = 2;
    int* arr = (int*)malloc(sizeof(int) * (n + 1));
    int* p = countBits(n,arr);

}